using DataTestFramework.NHibernate.Models;

using FluentNHibernate.Mapping;

using NHibernate.Mapping.ByCode;
using NHibernate.Mapping.ByCode.Conformist;


namespace DataTestFramework.NHibernate.Mappers
{
    public class NhOrderMapping : ClassMap<NhOrder>
    {
        public NhOrderMapping()
        {
            Table("Orders");
            Id(m => m.OrderId).GeneratedBy.Identity();
            Map(m => m.OrderDate);
            Map(m => m.SumMoney);
            Map(m => m.Comment).Length(300).Nullable();
            Map(m => m.Finished);
            Map(m => m.CustomerId);
            References(m => m.Customer).Column("CustomerId").ForeignKey("CustomerId").LazyLoad();
            HasMany(m => m.OrderDetails).KeyColumn("OrderId").LazyLoad();
        }
    }
}
